class ObjectRefImpl<T extends object, K extends keyof T> {
  public readonly __v_isRef = true;
  constructor(private readonly _object: T, private readonly _key: K) {}

  get value() {
    return this._object[this._key];
  }

  set value(newVal) {
    this._object[this._key] = newVal;
  }
}

type ObjType = {
  username: string;
  age: 23;
};

type ObjKeysType<T extends object, K extends keyof T> = K extends keyof T
  ? K
  : never;
type TetObjKeysType = ObjKeysType<ObjType, "username">;

const obj = new ObjectRefImpl<ObjType, "age">(
  { username: "lisi", age: 23 },
  "age"
);
console.log("obj", obj.value);

export {};
